package com.galina.notebook.persistence;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.CascadeType;
import javax.persistence.ElementCollection;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OrderColumn;
import javax.persistence.Table;

@Entity
@Table(name = "USER_DATA")
public class User implements Serializable {

	private static final long serialVersionUID = -9040144237362734468L;

	@Id
	private String idNumber;
	
	private String firstName;
	
	private String lastName;
	
	private Date birthdate;
	
	@ManyToMany(mappedBy = "users", cascade = CascadeType.ALL)
	private List<ParkingPlace> parkingPlaces = new ArrayList<ParkingPlace>();

	@Embedded
	@AttributeOverrides({ @AttributeOverride(name = "country", column = @Column(name = "COUNTRY_CODE")) })
	private Address address;
	
	@ElementCollection
	@OrderColumn(name="TELEPHONE_ORDER")
	List<Telephone> telephone;

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public Date getBirthdate() {
		return birthdate;
	}

	public void setBirthdate(Date birthdate) {
		this.birthdate = birthdate;
	}

	public String getIdNumber() {
		return idNumber;
	}

	public void setIdNumber(String idNumber) {
		this.idNumber = idNumber;
	}

	public List<ParkingPlace> getParkingPlaces() {
		return parkingPlaces;
	}

	public void setParkingPlaces(List<ParkingPlace> parkingPlaces) {
		this.parkingPlaces = parkingPlaces;
	}

	public List<Telephone> getTelephone() {
		return telephone;
	}

	public void setTelephone(List<Telephone> telephone) {
		this.telephone = telephone;
	}
}
